package com.xian.java.stream;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * 获取socket流数据
 */
public class GetSocketData {
    public static void main(String[] args) throws Exception {
        //获取执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        //测试环境，为了便于观察，这里设置并行度为1
        //env.setParallelism(1);

        DataStreamSource<String> dataStreamSource = env.socketTextStream("r71", 2323);

        dataStreamSource.print();


        //执行任务
        env.execute("GetSocketData");
    }
}
